package com.newbsd.web.maventest.controller;

import java.io.IOException;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.newbsd.web.maventest.pojo.Manager;
import com.newbsd.web.maventest.pojo.User;
import com.newbsd.web.maventest.service.UserService;
import com.newbsd.web.maventest.service.impl.UserServiceImpl;

/**
 * @author Mei
 */
@WebServlet("/addUser")
public class addUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		UserService userService = new UserServiceImpl();
		User user = new User();
	
		user.setCert(request.getParameter("cert"));
		user.setCertType(request.getParameter("certType"));
		
		user.setCity(request.getParameter("city"));
		user.setContent(request.getParameter("content"));
		user.setPassword(request.getParameter("password"));
		user.setProvince(request.getParameter("province"));
		user.setRealname(request.getParameter("realname"));
		user.setSex(request.getParameter("sex"));
		user.setUsername(request.getParameter("username"));
		user.setUserType(request.getParameter("userType"));
		
		userService.addUserManager(user);
		
		System.out.println("add Success"+user.toString());
		
		request.getRequestDispatcher("Admin/userQuery.jsp").forward(request, response);
	}

}
